/**
 * jTweener.easingFunctions is Tweener's easing functions (Penner's Easing
 * Equations) porting to JavaScript. http://code.google.com/p/tweener/
 * 
 * @author Robert Penner
 */

(function() {
	if (!window.jTweener || !jTweener.easingFunctions) {
		return;
	}

	jTweener.easingFunctions = jTweener.Utils.mergeObjects(
			jTweener.easingFunctions, {
				easeOutInCubic : function(t, b, c, d) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutCubic(t * 2, b,
								c / 2, d);
					return jTweener.easingFunctions.easeInCubic((t * 2) - d, b
							+ c / 2, c / 2, d);
				},

				easeInQuart : function(t, b, c, d) {
					return c * (t /= d) * t * t * t + b;
				},
				easeOutQuart : function(t, b, c, d) {
					return -c * ((t = t / d - 1) * t * t * t - 1) + b;
				},
				easeInOutQuart : function(t, b, c, d) {
					if ((t /= d / 2) < 1)
						return c / 2 * t * t * t * t + b;
					return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
				},
				easeOutInQuart : function(t, b, c, d) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutQuart(t * 2, b,
								c / 2, d);
					return jTweener.easingFunctions.easeInQuart((t * 2) - d, b
							+ c / 2, c / 2, d);
				},
				easeInQuint : function(t, b, c, d) {
					return c * (t /= d) * t * t * t * t + b;
				},
				easeOutQuint : function(t, b, c, d) {
					return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
				},
				easeInOutQuint : function(t, b, c, d) {
					if ((t /= d / 2) < 1)
						return c / 2 * t * t * t * t * t + b;
					return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
				},
				easeOutInQuint : function(t, b, c, d) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutQuint(t * 2, b,
								c / 2, d);
					return jTweener.easingFunctions.easeInQuint((t * 2) - d, b
							+ c / 2, c / 2, d);
				},
				easeInSine : function(t, b, c, d) {
					return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
				},
				easeOutSine : function(t, b, c, d) {
					return c * Math.sin(t / d * (Math.PI / 2)) + b;
				},
				easeInOutSine : function(t, b, c, d) {
					return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
				},
				easeOutInSine : function(t, b, c, d) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutSine(t * 2, b, c
								/ 2, d);
					return jTweener.easingFunctions.easeInSine((t * 2) - d, b
							+ c / 2, c / 2, d);
				},

				easeOutInExpo : function(t, b, c, d) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutExpo(t * 2, b, c
								/ 2, d);
					return jTweener.easingFunctions.easeInExpo((t * 2) - d, b
							+ c / 2, c / 2, d);
				},
				easeInCirc : function(t, b, c, d) {
					return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
				},
				easeOutCirc : function(t, b, c, d) {
					return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
				},
				easeInOutCirc : function(t, b, c, d) {
					if ((t /= d / 2) < 1)
						return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
					return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
				},
				easeOutInCirc : function(t, b, c, d) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutCirc(t * 2, b, c
								/ 2, d);
					return jTweener.easingFunctions.easeInCirc((t * 2) - d, b
							+ c / 2, c / 2, d);
				},

				easeOutInElastic : function(t, b, c, d, a, p) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutElastic(t * 2,
								b, c / 2, d, a, p);
					return jTweener.easingFunctions.easeInElastic((t * 2) - d,
							b + c / 2, c / 2, d, a, p);
				},

				easeOutInBack : function(t, b, c, d, s) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutBack(t * 2, b, c
								/ 2, d, s);
					return jTweener.easingFunctions.easeInBack((t * 2) - d, b
							+ c / 2, c / 2, d, s);
				},

				easeOutInBounce : function(t, b, c, d) {
					if (t < d / 2)
						return jTweener.easingFunctions.easeOutBounce(t * 2, b,
								c / 2, d);
					return jTweener.easingFunctions.easeInBounce((t * 2) - d, b
							+ c / 2, c / 2, d);
				}
			});
})();